
package com.ruoyi.system.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.TWorkOrderItemMapper;
import com.ruoyi.system.domain.TWorkOrderItem;
import com.ruoyi.system.service.ITWorkOrderItemService;

/**
 * 工单详情Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-05-26
 */
@Service
public class TWorkOrderItemServiceImpl implements ITWorkOrderItemService 
{
    @Autowired
    private TWorkOrderItemMapper tWorkOrderItemMapper;

    /**
     * 查询工单详情
     * 
     * @param id 工单详情主键
     * @return 工单详情
     */
    @Override
    public TWorkOrderItem selectTWorkOrderItemById(Long id)
    {
        return tWorkOrderItemMapper.selectTWorkOrderItemById(id);
    }

    /**
     * 查询工单详情列表
     * 
     * @param tWorkOrderItem 工单详情
     * @return 工单详情
     */
    @Override
    public List<TWorkOrderItem> selectTWorkOrderItemList(TWorkOrderItem tWorkOrderItem)
    {
        return tWorkOrderItemMapper.selectTWorkOrderItemList(tWorkOrderItem);
    }

    /**
     * 新增工单详情
     * 
     * @param tWorkOrderItem 工单详情
     * @return 结果
     */
    @Override
    public int insertTWorkOrderItem(TWorkOrderItem tWorkOrderItem)
    {
        //先设置全部关闭
        if (tWorkOrderItem.getStatus() == 1){
            tWorkOrderItemMapper.updateStatusByWorkOrderId(tWorkOrderItem.getWorkOrderId());
        }
        return tWorkOrderItemMapper.insertTWorkOrderItem(tWorkOrderItem);
    }

    /**
     * 修改工单详情
     * 
     * @param tWorkOrderItem 工单详情
     * @return 结果
     */
    @Override
    public int updateTWorkOrderItem(TWorkOrderItem tWorkOrderItem)
    {
        //先设置全部关闭
        if (tWorkOrderItem.getStatus() == 1){
            tWorkOrderItemMapper.updateStatusByWorkOrderId(tWorkOrderItem.getWorkOrderId());
        }
        return tWorkOrderItemMapper.updateTWorkOrderItem(tWorkOrderItem);
    }

    /**
     * 批量删除工单详情
     * 
     * @param ids 需要删除的工单详情主键
     * @return 结果
     */
    @Override
    public int deleteTWorkOrderItemByIds(Long[] ids)
    {
        return tWorkOrderItemMapper.deleteTWorkOrderItemByIds(ids);
    }

    /**
     * 删除工单详情信息
     * 
     * @param id 工单详情主键
     * @return 结果
     */
    @Override
    public int deleteTWorkOrderItemById(Long id)
    {
        return tWorkOrderItemMapper.deleteTWorkOrderItemById(id);
    }
}
